//
//  Vertex.swift
//  Chapter3LinkedList
//
//  Created by TRS-Mobile on 2021/9/3.
//

import Foundation

// 顶点

struct Vertex<T> {
    let index: Int
    let data: T
}

extension Vertex: Hashable {
    var hashValue: Int {
        return index.hashValue
    }
    
    func hash(into hasher: inout Hasher) {
        hasher.combine(index)
    }
    
    static func ==(lhs: Vertex, rhs: Vertex) -> Bool {
        return lhs.index == rhs.index
    }
}

extension Vertex: CustomStringConvertible {
    var description: String {
        return "\(index): \(data)"
    }
}
